#include "student.h"
#include "teacher.h"
#include<stdio.h>
#include<string.h>


bool IsNameEqual(void *p1,void* p2)
{
    Stu *s = (Stu*)p1;
    const char *str = (const char*)p2;
    return strcmp(s->Name,str) == 0;
}

bool IsIdEqual(void *p1,void* p2)
{
    Stu *s = (Stu*)p1;
    int *id = (int*)p2;
    return s->id == *id;
}

bool IsIdBigger(void *p1,void* p2)
{
    Stu *s = (Stu*)p1;
    int *id = (int*)p2;
    return s->id >= *id;
}

bool IsNameContain(void*p1,void *p2)
{
    Stu *s = (Stu*)p1;
    const char *str = (const char*)p2;
    if(strstr((const char *)(s->Name),str))
        return true;
    else
        return false;
}


// void RemoveByIndex(int *a,int size,int index)
// {
//     for(int i = index; i < size; i++)
//     {
//         a[i] = a[i+1];
//     }
// }

int main()
{
    // Stu s;
    // InitStu(&s,1,"zhangsan");
    // PrintStu(&s);

    Teach t;
    InitTeacher(&t,1,"zhangsan");
    AddStudent(&t,1,"wnagwu");
    AddStudent(&t,2,"zhaoliu");
    AddStudent(&t,2,"liliu");
    AddStudent(&t,3,"zip");

    // Stu* s = FindStudent(&t,"yiy",IsNameEqual);
    //     if(s)
    //         PrintStu(s);


    RemoveStudent(&t,"z",IsNameContain);


    // RemoveStudent(&t,"yiy",IsNameEqual);

    // int id = 2;
    // RemoveStudent(&t,&id,IsIdBigger);
    // RemoveStudent(&t,2);
    PrintTeach(&t);
    
    // int a[5] = {1,2,3,4,5};

    // RemoveByIndex(a,5,2);

    // for(int i = 0;i < 4; i++)
    // {
    //     printf("%d ",a[i]);
    // }
    // printf("\n");



    return 0;
}

